package com.seecoder.BlueWhale.repository;

import com.seecoder.BlueWhale.po.Commodity;
import com.seecoder.BlueWhale.po.Order;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CommodityRepository extends JpaRepository<Commodity, Integer> {
    Commodity findById(int id);

    List<Commodity> findAllByStoreId(int id);


    List<Commodity> findAll(Specification<Commodity> specification);

    @Query("SELECT o FROM Commodity o WHERE o.id = (SELECT MAX(o2.id) FROM Commodity o2)")
    Commodity findWithMaxId();
}